package com.xudd.third.config;

/*
*
* */

import com.xudd.third.websocket.ReverseWebSocketEndpoint;
import com.xudd.third.websocket.SimpleWebSocketHandler;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

import javax.websocket.server.ServerEndpoint;

@Configurable
@EnableWebSocket
public class webSocketConfig implements WebSocketConfigurer {

	@Override
	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
		registry.addHandler(sampleWebSocketHandler(),"/message");
	}

	@Bean
	public WebSocketHandler sampleWebSocketHandler(){
		return new SimpleWebSocketHandler();
	}

	@Bean
	public ReverseWebSocketEndpoint reverseWebSocketEndpoint(){
		return new ReverseWebSocketEndpoint();
	}
	@Bean
	public ServerEndpointExporter serverEndpoint(){
		return  new ServerEndpointExporter();
	}
}
